x86: Fix mod_l3_entry() for PAE-on-64 guests. The adjustment of
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 18 Feb 2008 13:50:25 +0000 (13:50 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 18 Feb 2008 13:50:25 +0000 (13:50 +0000)
_PAGE_RW and _PAGE_USER cannot happen before get_page_from_l3e().

Original patch by Manuel Bouyer <bouyer@netbsd.org>.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/mm.c

index 0b0e8c1d9430adbdb3fcfbc5379431822c6f03a9..469842787e78d0b82180650e5fb67f4739b8b523 100644 (file)
@@ -1443,16 +1443,18 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t nl1e,
             return 0;
         }
 
-        adjust_guest_l1e(nl1e, d);
-
         /* Fast path for identical mapping, r/w and presence. */
         if ( !l1e_has_changed(ol1e, nl1e, _PAGE_RW | _PAGE_PRESENT) )
+        {
+            adjust_guest_l1e(nl1e, d);
             return UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, curr,
                                 preserve_ad);
+        }
 
         if ( unlikely(!get_page_from_l1e(nl1e, FOREIGNDOM)) )
             return 0;
         
+        adjust_guest_l1e(nl1e, d);
         if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, curr,
                                     preserve_ad)) )
         {
@@ -1501,15 +1503,17 @@ static int mod_l2_entry(l2_pgentry_t *pl2e,
             return 0;
         }
 
-        adjust_guest_l2e(nl2e, d);
-
         /* Fast path for identical mapping and presence. */
-        if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT))
+        if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT) )
+        {
+            adjust_guest_l2e(nl2e, d);
             return UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, curr, preserve_ad);
+        }
 
         if ( unlikely(!get_page_from_l2e(nl2e, pfn, d)) )
             return 0;
 
+        adjust_guest_l2e(nl2e, d);
         if ( unlikely(!UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, pfn, curr,
                                     preserve_ad)) )
         {
@@ -1567,15 +1571,17 @@ static int mod_l3_entry(l3_pgentry_t *pl3e,
             return 0;
         }
 
-        adjust_guest_l3e(nl3e, d);
-
         /* Fast path for identical mapping and presence. */
-        if (!l3e_has_changed(ol3e, nl3e, _PAGE_PRESENT))
+        if ( !l3e_has_changed(ol3e, nl3e, _PAGE_PRESENT) )
+        {
+            adjust_guest_l3e(nl3e, d);
             return UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr, preserve_ad);
+        }
 
         if ( unlikely(!get_page_from_l3e(nl3e, pfn, d)) )
             return 0;
 
+        adjust_guest_l3e(nl3e, d);
         if ( unlikely(!UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, pfn, curr,
                                     preserve_ad)) )
         {
@@ -1630,15 +1636,17 @@ static int mod_l4_entry(l4_pgentry_t *pl4e,
             return 0;
         }
 
-        adjust_guest_l4e(nl4e, d);
-
         /* Fast path for identical mapping and presence. */
-        if (!l4e_has_changed(ol4e, nl4e, _PAGE_PRESENT))
+        if ( !l4e_has_changed(ol4e, nl4e, _PAGE_PRESENT) )
+        {
+            adjust_guest_l4e(nl4e, d);
             return UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr, preserve_ad);
+        }
 
         if ( unlikely(!get_page_from_l4e(nl4e, pfn, d)) )
             return 0;
 
+        adjust_guest_l4e(nl4e, d);
         if ( unlikely(!UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, pfn, curr,
                                     preserve_ad)) )
         {